package com.foxzzz.array;


import com.foxzzz.base.ArrayUtil;

public class Solution1089 {
    public void duplicateZeros(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 0) {

                for (int j = arr.length - 1; j > i; j--) {
                    arr[j]=arr[j-1];
                }
                if (i + 1 < arr.length) {
                    arr[i + 1] = 0;
                }
                i += 1;
            }
        }
    }

    public static void main(String[] args) {
        Solution1089 solution1089 = new Solution1089();
        int[] array = ArrayUtil.generator(1, 0, 2, 3, 0, 4, 5, 0);
        solution1089.duplicateZeros(array);
        ArrayUtil.visit(array);
    }
}
